package com.longe.controller;

import com.longe.common.Result;
import com.longe.entity.FriendRequest;
import com.longe.entity.vo.FriendRequestVO;
import com.longe.service.FriendRequestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author longe
 * @since 2020-05-23
 */
@RestController
@RequestMapping("/friend/request")
public class FriendRequestController {

    @Autowired
    private FriendRequestService friendRequestService;

    /**
     * 添加好友请求
     * @param friendReq
     * @return
     */
    @PostMapping
    public Result<Object> friendRequest(@RequestBody FriendRequest friendReq) {

        return friendRequestService.friendRequest(friendReq);
    }

    @PostMapping("/list")
    public Result<List<FriendRequestVO>> listFriendRequest(Integer userId) {

        return friendRequestService.listFriendRequest(userId);
    }

    @PostMapping("/accept")
    public Result<Object> friendRequestAccept(Integer reqId) {

        return friendRequestService.friendRequestAccept(reqId);
    }

    @PostMapping("/reject")
    public Result<Object> friendRequestReject(Integer reqId) {

        return friendRequestService.friendRequestReject(reqId);
    }
}
